package com.sun.showcase.controller.app.mall;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sun.showcase.biz.mall.service.ClassifyService;
import com.sun.showcase.client.query.mall.ClassifyQuery;
import com.sun.showcase.pojo.Result;
@CrossOrigin
@Controller("appClassifyController")
@RequestMapping(value="/app/classify") 
public class ClassifyController{
	
	@Autowired
	private ClassifyService classifyService;
	
	private Result result = new Result();

	/**
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="list")
	public Result list() {
		result.setSuccess(true);
		Map<String,Object> map = new HashMap<String,Object>();
		ClassifyQuery q = new ClassifyQuery();
		q.setQueryLevel("0");
		q.setOrderColum("order_num");
		q.setOrderRule("asc");
		q.setLevel(1);
		map.put("flist", classifyService.listAll(q));
		q.setQueryLevel("1");
		q.setLevel(2);
		map.put("slist", classifyService.listAll(q));
		q.setLevel(3);
		map.put("tlist", classifyService.listAll(q));
		//result.setData(classifyService.list4App());
		result.setData(map);
		return result;
	}

	/**
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="list2")
	public Result list2(@RequestParam(name="parentId",required=false)String parentId) {
		result.setSuccess(true);
		result.setData(classifyService.list4App(parentId));
		return result;
	}	
}
